package zj.it.bhne.gridengineeringsurvey.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import zj.it.bhne.gridengineeringsurvey.BaseActivity;
import zj.it.bhne.gridengineeringsurvey.MyApplication;
import zj.it.bhne.gridengineeringsurvey.R;
import zj.it.bhne.gridengineeringsurvey.entity.greendao.Items;
import zj.it.bhne.gridengineeringsurvey.myutils.greendao.ItemsDao;


/**
 * 在线项目详情的活动
 */
public class OnlineDetailsActivity extends BaseActivity implements View.OnClickListener {


    private Context context;
    private Long details;
    private int de_id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_online_details);
        context = this;
        Intent intent = getIntent();
        details = intent.getLongExtra("details", 0);
        de_id = intent.getIntExtra("de_id", 0);
        initView();
    }

    @SuppressLint("SetTextI18n")
    private void initView() {
        ImageButton activity_ib_back = findViewById(R.id.activity_ib_back);
        TextView activity_tv_title = findViewById(R.id.activity_tv_title);
        TextView activity_tv_save = findViewById(R.id.activity_tv_save);

        activity_ib_back.setOnClickListener(this);

        activity_tv_title.setText("在线项目详情");
        activity_tv_save.setText("");
        //Log.e("TAG", "initViewssssssvvvv: "+details+"   "+de_id );
        Items items = MyApplication.getInstances().getItemsDao().queryBuilder().where(ItemsDao.Properties.Id.eq(details)).build().list().get(0);
        //Log.e("信息",items.toString());
        TextView onde_ed_name = findViewById(R.id.result_ed_name);
        onde_ed_name.setText(items.getName());
        TextView onde_content = findViewById(R.id.onde_content);
        onde_content.setText(items.getNote());
        TextView add_sp_dengji = findViewById(R.id.add_sp_dengji);
        TextView add_sp_leixing = findViewById(R.id.add_sp_leixing);
        add_sp_dengji.setText(items.getVoltage()+"");
        add_sp_leixing.setText(items.getType()+"");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.activity_ib_back:
                Intent intent = new Intent(context, BottomActivity.class);
                intent.putExtra("item_id", de_id);
                startActivity(intent);
                break;
        }
    }

}
